<html>
<head><meta charset="utf-8"><title>remove layout calculation from assert_bits · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/remove.20layout.20calculation.20from.20assert_bits.html">remove layout calculation from assert_bits</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="154876924"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/remove%20layout%20calculation%20from%20assert_bits/near/154876924" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Björn Steinbrink <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/remove.20layout.20calculation.20from.20assert_bits.html#154876924">(Jan 10 2019 at 22:19)</a>:</h4>
<p>assert_bits already asserts that the value type equals the type that is being passed into the function, so it seems sensible to me to skip the size calculation, which is ultimately only used to assert that the size of the passed-in type is equal to the size stored in the const itself. My main motivation for this is that match checking calls assert_bits a ton of times for large matches ( &gt; 20M for unicode_normalization)  leading to millions of IMHO unneeded queries. Changing that cuts about 60-70% of the time from match checking for the unicode_normalization crate. Opinions?</p>



<a name="154878014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/remove%20layout%20calculation%20from%20assert_bits/near/154878014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/remove.20layout.20calculation.20from.20assert_bits.html#154878014">(Jan 10 2019 at 22:36)</a>:</h4>
<p>if removing code that supports assertions gives tremendous speed ups then by all means do that</p>



<a name="154878023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/remove%20layout%20calculation%20from%20assert_bits/near/154878023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/remove.20layout.20calculation.20from.20assert_bits.html#154878023">(Jan 10 2019 at 22:36)</a>:</h4>
<p>perhaps make it a cheaper assertion?</p>



<a name="154878081"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/remove%20layout%20calculation%20from%20assert_bits/near/154878081" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/remove.20layout.20calculation.20from.20assert_bits.html#154878081">(Jan 10 2019 at 22:38)</a>:</h4>
<p>final alternative is to make it a debug_assertion</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>